{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "c4b39799",
   "metadata": {},
   "source": [
    "# Wikidata\n",
    "\n",
    ">[Wikidata](https://wikidata.org/) is a free and open knowledge base that can be read and edited by both humans and machines. Wikidata is one of the world's largest open knowledge bases.\n",
    "\n",
    "First, you need to install `wikibase-rest-api-client` and `mediawikiapi` python packages."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3d9195d4",
   "metadata": {
    "vscode": {
     "languageId": "shellscript"
    }
   },
   "outputs": [],
   "source": [
    "%pip install --upgrade --quiet  wikibase-rest-api-client mediawikiapi"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "955988a1-ebc2-4c9a-9298-c493fe842de1",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain_community.tools.wikidata.tool import WikidataAPIWrapper, WikidataQueryRun\n",
    "\n",
    "wikidata = WikidataQueryRun(api_wrapper=WikidataAPIWrapper())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "9926a8a7-3e4e-4a97-ba43-7e5a274b9561",
   "metadata": {},
   "outputs": [],
   "source": [
    "print(wikidata.run(\"Alan Turing\"))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
